.class public Lcom/teewoo/app/bus/manager/collection/URLCollectionManager;
.super Ljava/lang/Object;
.source "URLCollectionManager.java"


# instance fields
.field private dbInstance:Lcom/teewoo/app/bus/db/collection/URLCollectionDBHelper;


# direct methods
.method public constructor <init>(Landroid/content/Context;)V
    .locals 1
    .parameter "context"

    .prologue
    .line 20
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 21
    new-instance v0, Lcom/teewoo/app/bus/db/collection/URLCollectionDBHelper;

    invoke-direct {v0, p1}, Lcom/teewoo/app/bus/db/collection/URLCollectionDBHelper;-><init>(Landroid/content/Context;)V

    iput-object v0, p0, Lcom/teewoo/app/bus/manager/collection/URLCollectionManager;->dbInstance:Lcom/teewoo/app/bus/db/collection/URLCollectionDBHelper;

    .line 22
    return-void
.end method


# virtual methods
.method public delete(Ljava/lang/Integer;)V
    .locals 4
    .parameter "id"

    .prologue
    .line 42
    iget-object v1, p0, Lcom/teewoo/app/bus/manager/collection/URLCollectionManager;->dbInstance:Lcom/teewoo/app/bus/db/collection/URLCollectionDBHelper;

    invoke-virtual {v1}, Lcom/teewoo/app/bus/db/collection/URLCollectionDBHelper;->getWritableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v0

    .line 43
    .local v0, database:Landroid/database/sqlite/SQLiteDatabase;
    const-string v1, "delete from url_collection where _id = ?"

    const/4 v2, 0x1

    new-array v2, v2, [Ljava/lang/Object;

    const/4 v3, 0x0

    aput-object p1, v2, v3

    invoke-virtual {v0, v1, v2}, Landroid/database/sqlite/SQLiteDatabase;->execSQL(Ljava/lang/String;[Ljava/lang/Object;)V

    .line 44
    invoke-virtual {v0}, Landroid/database/sqlite/SQLiteDatabase;->close()V

    .line 45
    return-void
.end method

.method public deleteAll()V
    .locals 3

    .prologue
    .line 52
    iget-object v1, p0, Lcom/teewoo/app/bus/manager/collection/URLCollectionManager;->dbInstance:Lcom/teewoo/app/bus/db/collection/URLCollectionDBHelper;

    invoke-virtual {v1}, Lcom/teewoo/app/bus/db/collection/URLCollectionDBHelper;->getWritableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v0

    .line 53
    .local v0, database:Landroid/database/sqlite/SQLiteDatabase;
    const-string v1, "delete from url_collection"

    const/4 v2, 0x0

    new-array v2, v2, [Ljava/lang/Object;

    invoke-virtual {v0, v1, v2}, Landroid/database/sqlite/SQLiteDatabase;->execSQL(Ljava/lang/String;[Ljava/lang/Object;)V

    .line 54
    invoke-virtual {v0}, Landroid/database/sqlite/SQLiteDatabase;->close()V

    .line 55
    return-void
.end method

.method public find(Ljava/lang/String;)Lcom/teewoo/app/bus/model/collection/URLCollection;
    .locals 7
    .parameter "url"

    .prologue
    const/4 v5, 0x1

    const/4 v4, 0x0

    .line 64
    iget-object v2, p0, Lcom/teewoo/app/bus/manager/collection/URLCollectionManager;->dbInstance:Lcom/teewoo/app/bus/db/collection/URLCollectionDBHelper;

    invoke-virtual {v2}, Lcom/teewoo/app/bus/db/collection/URLCollectionDBHelper;->getWritableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v1

    .line 66
    .local v1, database:Landroid/database/sqlite/SQLiteDatabase;
    const-string v2, "select * from url_collection where link = ?"

    .line 67
    new-array v3, v5, [Ljava/lang/String;

    aput-object p1, v3, v4

    .line 65
    invoke-virtual {v1, v2, v3}, Landroid/database/sqlite/SQLiteDatabase;->rawQuery(Ljava/lang/String;[Ljava/lang/String;)Landroid/database/Cursor;

    move-result-object v0

    .line 69
    .local v0, cursor:Landroid/database/Cursor;
    invoke-interface {v0}, Landroid/database/Cursor;->moveToNext()Z

    move-result v2

    if-eqz v2, :cond_0

    .line 70
    invoke-virtual {v1}, Landroid/database/sqlite/SQLiteDatabase;->close()V

    .line 71
    new-instance v2, Lcom/teewoo/app/bus/model/collection/URLCollection;

    invoke-interface {v0, v4}, Landroid/database/Cursor;->getInt(I)I

    move-result v3

    invoke-static {v3}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v3

    invoke-interface {v0, v5}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;

    move-result-object v4

    .line 72
    const/4 v5, 0x2

    invoke-interface {v0, v5}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;

    move-result-object v5

    const/4 v6, 0x3

    invoke-interface {v0, v6}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;

    move-result-object v6

    .line 71
    invoke-direct {v2, v3, v4, v5, v6}, Lcom/teewoo/app/bus/model/collection/URLCollection;-><init>(Ljava/lang/Integer;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V

    .line 75
    :goto_0
    return-object v2

    .line 74
    :cond_0
    invoke-virtual {v1}, Landroid/database/sqlite/SQLiteDatabase;->close()V

    .line 75
    const/4 v2, 0x0

    goto :goto_0
.end method

.method public getCount()J
    .locals 4

    .prologue
    .line 149
    iget-object v2, p0, Lcom/teewoo/app/bus/manager/collection/URLCollectionManager;->dbInstance:Lcom/teewoo/app/bus/db/collection/URLCollectionDBHelper;

    invoke-virtual {v2}, Lcom/teewoo/app/bus/db/collection/URLCollectionDBHelper;->getWritableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v1

    .line 151
    .local v1, database:Landroid/database/sqlite/SQLiteDatabase;
    const-string v2, "select count(*) from url_collection"

    const/4 v3, 0x0

    .line 150
    invoke-virtual {v1, v2, v3}, Landroid/database/sqlite/SQLiteDatabase;->rawQuery(Ljava/lang/String;[Ljava/lang/String;)Landroid/database/Cursor;

    move-result-object v0

    .line 153
    .local v0, cursor:Landroid/database/Cursor;
    invoke-interface {v0}, Landroid/database/Cursor;->moveToNext()Z

    move-result v2

    if-eqz v2, :cond_0

    .line 154
    invoke-interface {v0}, Landroid/database/Cursor;->close()V

    .line 155
    invoke-virtual {v1}, Landroid/database/sqlite/SQLiteDatabase;->close()V

    .line 156
    const/4 v2, 0x0

    invoke-interface {v0, v2}, Landroid/database/Cursor;->getLong(I)J

    move-result-wide v2

    .line 160
    :goto_0
    return-wide v2

    .line 158
    :cond_0
    invoke-interface {v0}, Landroid/database/Cursor;->close()V

    .line 159
    invoke-virtual {v1}, Landroid/database/sqlite/SQLiteDatabase;->close()V

    .line 160
    const-wide/16 v2, 0x0

    goto :goto_0
.end method

.method public getRawScrollURLCollection(II)Landroid/database/Cursor;
    .locals 6
    .parameter "startResult"
    .parameter "maxResult"

    .prologue
    .line 127
    iget-object v2, p0, Lcom/teewoo/app/bus/manager/collection/URLCollectionManager;->dbInstance:Lcom/teewoo/app/bus/db/collection/URLCollectionDBHelper;

    invoke-virtual {v2}, Lcom/teewoo/app/bus/db/collection/URLCollectionDBHelper;->getReadableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v1

    .line 129
    .local v1, database:Landroid/database/sqlite/SQLiteDatabase;
    const-string v2, "select * from url_collection ORDER BY save_time DESC limit ?,?"

    .line 130
    const/4 v3, 0x2

    new-array v3, v3, [Ljava/lang/String;

    const/4 v4, 0x0

    invoke-static {p1}, Ljava/lang/String;->valueOf(I)Ljava/lang/String;

    move-result-object v5

    aput-object v5, v3, v4

    const/4 v4, 0x1

    .line 131
    invoke-static {p2}, Ljava/lang/String;->valueOf(I)Ljava/lang/String;

    move-result-object v5

    aput-object v5, v3, v4

    .line 128
    invoke-virtual {v1, v2, v3}, Landroid/database/sqlite/SQLiteDatabase;->rawQuery(Ljava/lang/String;[Ljava/lang/String;)Landroid/database/Cursor;

    move-result-object v0

    .line 133
    .local v0, cursor:Landroid/database/Cursor;
    invoke-interface {v0}, Landroid/database/Cursor;->moveToNext()Z

    move-result v2

    if-eqz v2, :cond_0

    .line 134
    invoke-interface {v0}, Landroid/database/Cursor;->close()V

    .line 135
    invoke-virtual {v1}, Landroid/database/sqlite/SQLiteDatabase;->close()V

    move-object v2, v0

    .line 140
    :goto_0
    return-object v2

    .line 138
    :cond_0
    invoke-interface {v0}, Landroid/database/Cursor;->close()V

    .line 139
    invoke-virtual {v1}, Landroid/database/sqlite/SQLiteDatabase;->close()V

    .line 140
    const/4 v2, 0x0

    goto :goto_0
.end method

.method public getScrollData(II)Ljava/util/List;
    .locals 11
    .parameter "startResult"
    .parameter "maxResult"
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(II)",
            "Ljava/util/List",
            "<",
            "Lcom/teewoo/app/bus/model/collection/URLCollection;",
            ">;"
        }
    .end annotation

    .prologue
    const/4 v10, 0x2

    const/4 v9, 0x1

    const/4 v8, 0x0

    .line 103
    new-instance v2, Ljava/util/ArrayList;

    invoke-direct {v2}, Ljava/util/ArrayList;-><init>()V

    .line 104
    .local v2, list:Ljava/util/List;,"Ljava/util/List<Lcom/teewoo/app/bus/model/collection/URLCollection;>;"
    iget-object v3, p0, Lcom/teewoo/app/bus/manager/collection/URLCollectionManager;->dbInstance:Lcom/teewoo/app/bus/db/collection/URLCollectionDBHelper;

    invoke-virtual {v3}, Lcom/teewoo/app/bus/db/collection/URLCollectionDBHelper;->getReadableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v1

    .line 106
    .local v1, database:Landroid/database/sqlite/SQLiteDatabase;
    const-string v3, "select * from url_collection ORDER BY save_time DESC limit ?,?"

    .line 107
    new-array v4, v10, [Ljava/lang/String;

    invoke-static {p1}, Ljava/lang/String;->valueOf(I)Ljava/lang/String;

    move-result-object v5

    aput-object v5, v4, v8

    invoke-static {p2}, Ljava/lang/String;->valueOf(I)Ljava/lang/String;

    move-result-object v5

    aput-object v5, v4, v9

    .line 105
    invoke-virtual {v1, v3, v4}, Landroid/database/sqlite/SQLiteDatabase;->rawQuery(Ljava/lang/String;[Ljava/lang/String;)Landroid/database/Cursor;

    move-result-object v0

    .line 108
    .local v0, cursor:Landroid/database/Cursor;
    invoke-interface {v0}, Landroid/database/Cursor;->moveToFirst()Z

    move-result v3

    if-eqz v3, :cond_1

    .line 110
    :cond_0
    new-instance v3, Lcom/teewoo/app/bus/model/collection/URLCollection;

    invoke-interface {v0, v8}, Landroid/database/Cursor;->getInt(I)I

    move-result v4

    invoke-static {v4}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v4

    invoke-interface {v0, v9}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;

    move-result-object v5

    .line 111
    invoke-interface {v0, v10}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;

    move-result-object v6

    const/4 v7, 0x3

    invoke-interface {v0, v7}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;

    move-result-object v7

    invoke-direct {v3, v4, v5, v6, v7}, Lcom/teewoo/app/bus/model/collection/URLCollection;-><init>(Ljava/lang/Integer;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V

    .line 110
    invoke-interface {v2, v3}, Ljava/util/List;->add(Ljava/lang/Object;)Z

    .line 112
    invoke-interface {v0}, Landroid/database/Cursor;->moveToNext()Z

    move-result v3

    .line 109
    if-nez v3, :cond_0

    .line 115
    :cond_1
    invoke-interface {v0}, Landroid/database/Cursor;->close()V

    .line 116
    invoke-virtual {v1}, Landroid/database/sqlite/SQLiteDatabase;->close()V

    .line 117
    return-object v2
.end method

.method public save(Lcom/teewoo/app/bus/model/collection/URLCollection;)V
    .locals 5
    .parameter "urlCol"

    .prologue
    .line 30
    iget-object v1, p0, Lcom/teewoo/app/bus/manager/collection/URLCollectionManager;->dbInstance:Lcom/teewoo/app/bus/db/collection/URLCollectionDBHelper;

    invoke-virtual {v1}, Lcom/teewoo/app/bus/db/collection/URLCollectionDBHelper;->getWritableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v0

    .line 31
    .local v0, database:Landroid/database/sqlite/SQLiteDatabase;
    const-string v1, "insert into url_collection (title, link, save_time) values ( ?, ?, ?);"

    .line 32
    const/4 v2, 0x3

    new-array v2, v2, [Ljava/lang/Object;

    const/4 v3, 0x0

    invoke-virtual {p1}, Lcom/teewoo/app/bus/model/collection/URLCollection;->getTitle()Ljava/lang/String;

    move-result-object v4

    aput-object v4, v2, v3

    const/4 v3, 0x1

    invoke-virtual {p1}, Lcom/teewoo/app/bus/model/collection/URLCollection;->getLink()Ljava/lang/String;

    move-result-object v4

    aput-object v4, v2, v3

    const/4 v3, 0x2

    invoke-virtual {p1}, Lcom/teewoo/app/bus/model/collection/URLCollection;->getSaveTime()Ljava/lang/String;

    move-result-object v4

    aput-object v4, v2, v3

    .line 31
    invoke-virtual {v0, v1, v2}, Landroid/database/sqlite/SQLiteDatabase;->execSQL(Ljava/lang/String;[Ljava/lang/Object;)V

    .line 33
    invoke-virtual {v0}, Landroid/database/sqlite/SQLiteDatabase;->close()V

    .line 34
    return-void
.end method

.method public update(Lcom/teewoo/app/bus/model/collection/URLCollection;)V
    .locals 5
    .parameter "urlCol"

    .prologue
    .line 85
    iget-object v1, p0, Lcom/teewoo/app/bus/manager/collection/URLCollectionManager;->dbInstance:Lcom/teewoo/app/bus/db/collection/URLCollectionDBHelper;

    invoke-virtual {v1}, Lcom/teewoo/app/bus/db/collection/URLCollectionDBHelper;->getWritableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v0

    .line 87
    .local v0, database:Landroid/database/sqlite/SQLiteDatabase;
    const-string v1, "update url_collection set title=?,link=?,save_time=? where _id=?"

    .line 88
    const/4 v2, 0x4

    new-array v2, v2, [Ljava/lang/Object;

    const/4 v3, 0x0

    invoke-virtual {p1}, Lcom/teewoo/app/bus/model/collection/URLCollection;->getTitle()Ljava/lang/String;

    move-result-object v4

    aput-object v4, v2, v3

    const/4 v3, 0x1

    .line 89
    invoke-virtual {p1}, Lcom/teewoo/app/bus/model/collection/URLCollection;->getLink()Ljava/lang/String;

    move-result-object v4

    aput-object v4, v2, v3

    const/4 v3, 0x2

    invoke-virtual {p1}, Lcom/teewoo/app/bus/model/collection/URLCollection;->getSaveTime()Ljava/lang/String;

    move-result-object v4

    aput-object v4, v2, v3

    const/4 v3, 0x3

    .line 90
    invoke-virtual {p1}, Lcom/teewoo/app/bus/model/collection/URLCollection;->getId()Ljava/lang/Integer;

    move-result-object v4

    aput-object v4, v2, v3

    .line 86
    invoke-virtual {v0, v1, v2}, Landroid/database/sqlite/SQLiteDatabase;->execSQL(Ljava/lang/String;[Ljava/lang/Object;)V

    .line 91
    invoke-virtual {v0}, Landroid/database/sqlite/SQLiteDatabase;->close()V

    .line 92
    return-void
.end method
